﻿using Cxuu.Service;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;

namespace Cxuu.Web.Home
{
    [Area("Home")]
    public class SearchController : Base
    {
        private readonly ContentService _contentService;

        public SearchController(ContentService contentService)
        {
            _contentService = contentService;
        }

        /// <summary>
        /// 全部内容页列表 分页
        /// </summary>
        /// <param name="keyword"></param>
        /// <param name="page"></param>
        /// <param name="limit"></param>
        /// <returns></returns>
        [HttpGet]
        //[XssFieldFilter]//防Xss
        public async Task<IActionResult> IndexAsync(string keyword, int page = 1, int limit = 15)
        {
            if (string.IsNullOrEmpty(keyword))
            {
                return Ok("keyword is null");
            }
            var pagedList = await _contentService.ContentSearchPageList(page, limit, keyword);
            ViewBag.keyword = keyword;
            return View(pagedList);
        }

    }
}
